#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import os

import cairosvg

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print(f'Usage: {sys.argv[0]} <input file> <output file>')
        sys.exit(0)
    source = sys.argv[1]
    if not os.path.exists(source):
        raise RuntimeError(f'File {source} does not exist')
    svg = open(source, 'r').read()
    png = cairosvg.svg2png(bytestring=svg)
    with open(sys.argv[2], "wb") as f:
        f.write(png)
